/* 
 * @(#)RMIManager.java 2012-5-2
 * Copyright (c) 2012
 * Dark-J (Zh)Co., Ltd.
 * Dark-J R&D,BeiJing
 *
 * All Rights Reserved
 * 
 * Revision History:
 * 								Modification	 Traking
 * Author (Email ID)			Date			 Number				Description
 * ----------------------------------------------------------------------------------
 * yongchong.bai				2012-6-20		 					Initial Version
 */
package com.jworktogether.zse.jmx;

/**
 * @author baiyc
 *
 */

import javax.management.Attribute;
import javax.management.ObjectName;
import com.sun.jdmk.comm.RmiConnectorAddress;
import com.sun.jdmk.comm.RmiConnectorClient;

public class RMIManager {

	public static void main(String[] args) {
		RmiConnectorClient client = new RmiConnectorClient();
		RmiConnectorAddress address = new RmiConnectorAddress();
		try {
			client.connect(address);
			ObjectName testMBeanName = ObjectName
					.getInstance("RMIAgent:name=testMBean");
			client.invoke(testMBeanName, "fun", null, null);
			client.setAttribute(testMBeanName, new Attribute("Field",
					new String("hello JMX from manager!")));
			System.out.println(client.invoke(testMBeanName, "fun", null, null));
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

		}
	}
}
